﻿/* $RCSFile: ADNDynCustomer.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/CRMWrapper3/DynEntities/ADNDynCustomer.cs $
 * $log$
 * Revision 19 2010/10/02 14:03:23  christian.surieux
 *   Corrected a bug in Crm2Crm concerning RetrieveLookup
 * Revision 6 2010/08/06 19:56:32  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using CrmSdk;

namespace AddonNice.CRMWrapper
{
    public class ADNDynCustomer: DynEntity
    {
        public override bool HasOwningBusinessUnitProperty
        {
            get{   return true;}
        }

        /// <summary>
		/// Reserved for template methods: do not use directly
		/// </summary>
        public ADNDynCustomer(): base()
		{}

        /// <summary>
        /// Ctor for querying crm to find corresponding account/contact
        /// </summary>
        public ADNDynCustomer(CRMWrapperBase w,string entname, Guid CrmId)
            : base(w, entname, CrmId)
        {}

        public ADNDynCustomer(CRMWrapperBase w, string entname)
            : base(w, entname)
        {}

        public ADNDynCustomer(CRMWrapperBase w, string entName,InternalDynamicEntity dEntity, PropertyDescriptorCollection prop, InternalColumnSet s)
            : base(w, entName,dEntity, prop, s)
        {}

        /// <summary>
        /// Ctor for querying crm to find corresponding account/contact
        /// </summary>
        public ADNDynCustomer(ResetWrapperHandler fn,string entname, Guid CrmId)
            : base(fn, entname, CrmId)
        { }

        public ADNDynCustomer(ResetWrapperHandler fn, string entname)
            : base(fn, entname)
        {}

        public ADNDynCustomer(ResetWrapperHandler fn, string entName,InternalDynamicEntity dEntity, PropertyDescriptorCollection prop, InternalColumnSet s)
            : base(fn, entName,dEntity, prop, s)
        {}

        /// <summary>
        /// Utility to get the value in PrimaryFieldName
        /// </summary>
        public string customerName
        {
            get
            {
                return StringPropertyValue(PrimaryFieldName);
            }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string emailaddress1
		{
			get
			{
				return StringPropertyValue(CrmStr.emailaddress1);
			}
			set
			{
				AddStringProperty(CrmStr.emailaddress1,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
		public string emailaddress2
		{
			get
			{
				return StringPropertyValue(CrmStr.emailaddress2);
			}
			set
			{
				AddStringProperty(CrmStr.emailaddress2,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
		public string emailaddress3
		{
			get
			{
				return StringPropertyValue(CrmStr.emailaddress3);
			}
			set
			{
				AddStringProperty(CrmStr.emailaddress3,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
		public string fax
		{
			get
			{
				return StringPropertyValue(CrmStr.fax);
			}
			set
			{
				AddStringProperty(CrmStr.fax,value);
			}
		}

       
        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
		public string telephone1
		{
			get
			{
				return StringPropertyValue(CrmStr.telephone1);
			}
			set
			{
				AddStringProperty(CrmStr.telephone1,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
		public string telephone2
		{
			get
			{
				return StringPropertyValue(CrmStr.telephone2);
			}
			set
			{
				AddStringProperty(CrmStr.telephone2,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
		public string telephone3
		{
			get
			{
				return StringPropertyValue(CrmStr.telephone3);
			}
			set
			{
				AddStringProperty(CrmStr.telephone3,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public bool donotsendmm
        {
            get
            {
                if ( ContainsKey(CrmStr.donotsendmm) )
				    return BooleanPropertyValue(CrmStr.donotsendmm);
                return false;
            }
            set 
             {
				AddBooleanProperty(CrmStr.donotsendmm,value);
             }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string description
        {
            get
            {
                return StringPropertyValue(CrmStr.description);
            }
            set
            {
                AddStringProperty(CrmStr.description,value);
            }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string lastusedincampaign
        {
            get
            {
                if ( ContainsKey(CrmStr.lastusedincampaign) )
                    return DateTimePropertyValue(CrmStr.lastusedincampaign);
                return string.Empty;
            }
            set
            {
                AddDateTimeProperty(CrmStr.lastusedincampaign,value);
            }
        }

        public DateTime lastusedincampaignUTCDate
        {
            get
            {
                if ( ContainsKey(CrmStr.lastusedincampaign) )
                    return DateTimePropertyDate(CrmStr.lastusedincampaign,false);
                return CRMUtil.minDateTime;
            }
        }

        public DateTime lastusedincampaignLocalDate
        {
            get
            {
                if ( ContainsKey(CrmStr.lastusedincampaign) )
                    return DateTimePropertyDate(CrmStr.lastusedincampaign,true);
                return CRMUtil.minDateTime;
            }
        }

        #region address1

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_primarycontactname
		{
			get
			{
				return StringPropertyValue(CrmStr.address1_primarycontactname);
			}
			set
			{
				AddStringProperty(CrmStr.address1_primarycontactname,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public int address1_addresstypecode
		{
			get
			{
				return PicklistPropertyIntValue(CrmStr.address1_addresstypecode);
			}
			set
			{
				AddPicklistProperty(CrmStr.address1_addresstypecode,value);
			}
		}
       
        public string address1_addresstypecodeLabel
        {
            get
            {
                if ( ContainsKey(CrmStr.address1_addresstypecode) )
                    return PicklistPropertyLabelValue(CrmStr.address1_addresstypecode);
                return string.Empty;
            }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public int address1_shippingmethodcode
		{
			get
			{
				return PicklistPropertyIntValue(CrmStr.address1_shippingmethodcode);
			}
			set
			{
				AddPicklistProperty(CrmStr.address1_shippingmethodcode,value);
			}
		}

        public string address1_shippingmethodcodeLabel
        {
            get
            {
                if ( ContainsKey(CrmStr.address1_shippingmethodcode) )
                    return PicklistPropertyLabelValue(CrmStr.address1_shippingmethodcode);
                return string.Empty;
            }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_name
		{
			get
			{
				return StringPropertyValue(CrmStr.address1_name);
			}
			set
			{
				AddStringProperty(CrmStr.address1_name,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_telephone1
		{
			get
			{
				return StringPropertyValue(CrmStr.address1_telephone1);
			}
			set
			{
				AddStringProperty(CrmStr.address1_telephone1,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_telephone2
		{
			get
			{
				return StringPropertyValue(CrmStr.address1_telephone2);
			}
			set
			{
				AddStringProperty(CrmStr.address1_telephone2,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_telephone3
		{
			get
			{
				return StringPropertyValue(CrmStr.address1_telephone3);
			}
			set
			{
				AddStringProperty(CrmStr.address1_telephone3,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_fax
		{
			get
			{
				return StringPropertyValue(CrmStr.address1_fax);
			}
			set
			{
				AddStringProperty(CrmStr.address1_fax,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_line1
		{
			get
			{
				return StringPropertyValue(CrmStr.address1_line1);
			}
			set
			{
				AddStringProperty(CrmStr.address1_line1,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_line2
		{
			get
			{
				return StringPropertyValue(CrmStr.address1_line2);
			}
			set
			{
				AddStringProperty(CrmStr.address1_line2,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_line3
		{
			get
			{
				return StringPropertyValue(CrmStr.address1_line3);
			}
			set
			{
				AddStringProperty(CrmStr.address1_line3,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_country
        {
            get
            {
				return StringPropertyValue(CrmStr.address1_country);
            }
            set
            {
				AddStringProperty(CrmStr.address1_country,value);
            }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_county
        {
            get
            {
				return StringPropertyValue(CrmStr.address1_county);
            }
            set
            {
				AddStringProperty(CrmStr.address1_county,value);
            }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_postalcode
        {
            get
            {
				return StringPropertyValue(CrmStr.address1_postalcode);
            }
            set 
             {
				AddStringProperty(CrmStr.address1_postalcode,value);
              }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_city
        {
            get
            {
				return StringPropertyValue(CrmStr.address1_city);
            }
            set 
             {
				AddStringProperty(CrmStr.address1_city,value);
             }
        }
       
        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_stateorprovince
        {
            get
            {
				return StringPropertyValue(CrmStr.address1_stateorprovince);
            }
            set 
             {
				AddStringProperty(CrmStr.address1_stateorprovince,value);
             }
        }
       
        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address1_upszone
        {
            get
            {
				return StringPropertyValue(CrmStr.address1_upszone);
            }
            set 
             {
				AddStringProperty(CrmStr.address1_upszone,value);
             }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public double address1_longitude
        {
            get
            {
				return DoublePropertyValue(CrmStr.address1_longitude);
            }
            set 
             {
				AddFloatProperty(CrmStr.address1_longitude,value);
             }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public double address1_latitude
        {
            get
            {
				return DoublePropertyValue(CrmStr.address1_latitude);
            }
            set 
             {
				AddFloatProperty(CrmStr.address1_latitude,value);
             }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public int address1_utcoffset
        {
            get
            {
                if ( ContainsKey(CrmStr.address1_utcoffset) )
                    return NumberPropertyValue(CrmStr.address1_utcoffset);
                return 0;
            }
            set
            {
                AddNumberProperty(CrmStr.address1_utcoffset,value);
            }
        }
        
        #endregion address1
   
        #region address2

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_primarycontactname
		{
			get
			{
				return StringPropertyValue(CrmStr.address2_primarycontactname);
			}
			set
			{
				AddStringProperty(CrmStr.address2_primarycontactname,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public int address2_addresstypecode
		{
			get
			{
				return PicklistPropertyIntValue(CrmStr.address2_addresstypecode);
			}
			set
			{
				AddPicklistProperty(CrmStr.address2_addresstypecode,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_addresstypecodeLabel
        {
            get
            {
                if ( ContainsKey(CrmStr.address2_addresstypecode) )
                    return PicklistPropertyLabelValue(CrmStr.address2_addresstypecode);
                return string.Empty;
            }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public int address2_shippingmethodcode
		{
			get
			{
				return PicklistPropertyIntValue(CrmStr.address2_shippingmethodcode);
			}
			set
			{
				AddPicklistProperty(CrmStr.address2_shippingmethodcode,value);
			}
		}

        public string address2_shippingmethodcodeLabel
        {
            get
            {
                if ( ContainsKey(CrmStr.address2_shippingmethodcode) )
                    return PicklistPropertyLabelValue(CrmStr.address2_shippingmethodcode);
                return string.Empty;
            }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_name
		{
			get
			{
				return StringPropertyValue(CrmStr.address2_name);
			}
			set
			{
				AddStringProperty(CrmStr.address2_name,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_telephone1
		{
			get
			{
				return StringPropertyValue(CrmStr.address2_telephone1);
			}
			set
			{
				AddStringProperty(CrmStr.address2_telephone1,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_telephone2
		{
			get
			{
				return StringPropertyValue(CrmStr.address2_telephone2);
			}
			set
			{
				AddStringProperty(CrmStr.address2_telephone2,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_telephone3
		{
			get
			{
				return StringPropertyValue(CrmStr.address2_telephone3);
			}
			set
			{
				AddStringProperty(CrmStr.address2_telephone3,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_fax
		{
			get
			{
				return StringPropertyValue(CrmStr.address2_fax);
			}
			set
			{
				AddStringProperty(CrmStr.address2_fax,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_line1
		{
			get
			{
				return StringPropertyValue(CrmStr.address2_line1);
			}
			set
			{
				AddStringProperty(CrmStr.address2_line1,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_line2
		{
			get
			{
				return StringPropertyValue(CrmStr.address2_line2);
			}
			set
			{
				AddStringProperty(CrmStr.address2_line2,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_line3
		{
			get
			{
				return StringPropertyValue(CrmStr.address2_line3);
			}
			set
			{
				AddStringProperty(CrmStr.address2_line3,value);
			}
		}

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_country
        {
            get
            {
				return StringPropertyValue(CrmStr.address2_country);
            }
            set
            {
				AddStringProperty(CrmStr.address2_country,value);
            }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_county
        {
            get
            {
				return StringPropertyValue(CrmStr.address2_county);
            }
            set
            {
				AddStringProperty(CrmStr.address2_county,value);
            }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_postalcode
        {
            get
            {
				return StringPropertyValue(CrmStr.address2_postalcode);
            }
            set 
             {
				AddStringProperty(CrmStr.address2_postalcode,value);
              }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_city
        {
            get
            {
				return StringPropertyValue(CrmStr.address2_city);
            }
            set 
             {
				AddStringProperty(CrmStr.address2_city,value);
             }
        }
       
        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_stateorprovince
        {
            get
            {
				return StringPropertyValue(CrmStr.address2_stateorprovince);
            }
            set 
             {
				AddStringProperty(CrmStr.address2_stateorprovince,value);
             }
        }
       
        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public string address2_upszone
        {
            get
            {
				return StringPropertyValue(CrmStr.address2_upszone);
            }
            set 
             {
				AddStringProperty(CrmStr.address2_upszone,value);
             }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public double address2_longitude
        {
            get
            {
				return DoublePropertyValue(CrmStr.address2_longitude);
            }
            set 
             {
				AddFloatProperty(CrmStr.address2_longitude,value);
             }
        }

        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public double address2_latitude
        {
            get
            {
				return DoublePropertyValue(CrmStr.address2_latitude);
            }
            set 
             {
				AddFloatProperty(CrmStr.address2_latitude,value);
             }
        }
         
        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public int address2_utcoffset
        {
            get
            {
                if ( ContainsKey(CrmStr.address2_utcoffset) )
                    return NumberPropertyValue(CrmStr.address2_utcoffset);
                return 0;
            }
            set
            {
                AddNumberProperty(CrmStr.address2_utcoffset,value);
            }
        }

        #endregion address2

        /// <summary>
        /// Gets and sets the ID of the currency associated with the product.         
        /// </summary>
        [CrmDynAttribute(CrmStr.account),CrmDynAttribute(CrmStr.contact),CrmDynAttribute(CrmStr.lead)]
        public Guid transactioncurrencyid
        {
            get
            {
                return LookupPropertyValue(CrmStr.transactioncurrencyid);
            }
            set
            {
                AddLookupProperty(CrmStr.transactioncurrencyid,CrmStr.transactioncurrency,value);
            }
        }

        public string transactioncurrencyName
        {
            get
            {
                return LookupPropertyName(CrmStr.transactioncurrencyid);
            }
        }

        public string owningbusinessunitName
        {
            get
            {
                return LookupPropertyName(CrmStr.owningbusinessunit);
            }
        }
     }
}
